import React from 'react';
import ReactDOM from 'react-dom';
import { withRouter, HashRouter } from 'react-router-dom';

import IntlProvider from '@/locales/index';
import routes, { suspenseRenderRoutes } from './routers';
import { Provider } from './stores';

import { ErrorBoundary } from './components/ErrorBoundary';
import '@/assets/css/index.less';

const isDev = process.env.NODE_ENV === 'development';

const MainRoute = withRouter(() => suspenseRenderRoutes({ routes: routes as any[] }));

function App() {
  return (
    <ErrorBoundary>
      <HashRouter>
        <Provider>
          <IntlProvider>
            <MainRoute />
          </IntlProvider>
        </Provider>
      </HashRouter>
    </ErrorBoundary>
  );
}
if (isDev) {
  import('antd/dist/antd.less').then(() => {
    ReactDOM.render(<App />, document.getElementById('root'));
  });
} else {
  ReactDOM.render(<App />, document.getElementById('root'));
}
